<?php

namespace app\common\model\Subject;

use think\Model;
use traits\model\SoftDelete;

class Category extends Model
{
    use SoftDelete;
    // 表名
    protected $name = 'subject_category';
    // 忽略数据表不存在的字段
    protected $field = true;
    // 设置返回的结果类型
    protected $resultSetType = 'collection';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = 'deletetime';
    // 追加属性
    protected $append = [];

    public function getCategoryAll()
    {
        return $this->field('id,name')->where('deletetime','null')->order('weight','desc')->select();
    }
}
